#include <QApplication>
#include <QWidget>
#include <QDebug>

//cc-engine里面生成的动态库
#include "CcDataManage.h"
#include "CcJsonTool.h"

#include "cc-test/CcTestVideoPlayer.h"
#include "cc-test/CcTestVideoSurface.h"

//测试graphic view

void test_qJson()
{
    //TODO: qt json 简单使用测试
    auto cmd = 1001;
    auto type = 1;
    auto content = "05:00";

    QVariantMap contentMap;
    contentMap["cmd"] = QString::number(cmd);

    QVariantMap dataMap;
    dataMap["type"] = type;
    dataMap["content"] = content;

    contentMap["data"] = dataMap;

    CcJsonTool jsonTool;
    auto str = jsonTool.toJsonFromVariantMap(contentMap);

    qDebug() << "jsonStr:" << str;

    //jsonStr
    auto JsonStr = "{\"cmd\":\"1001\",\"data\":{\"content\":\"05:00\",\"type\":1}}";
    if (jsonTool.parseJsonFromString(JsonStr))
    {
        qDebug() << "parse json str success";
    }
    else
    {
        qDebug() << "parse json str failed";
    }
}

void test_dll_manage()
{
    CcDataManage data_manage;
    qDebug() << "Get Data From cc-engine dynamic library: " << data_manage.GetCurrentJsonData();
}

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);
  
    //Qt json 简单测试
    test_qJson();
    
    //一个项目多个子项目，并且子项目是动态库调用测试
    test_dll_manage();
    
    //QGraphicView和QGraphicScene简单测试
    auto videoSurface = new CcTestVideoSurface();
    videoSurface->showTips();
    auto graphicView = new CcTestVideoPlayer(nullptr, new CcTestVideoSurface());
    graphicView->setFixedSize(QSize(520, 420));
    graphicView->show();
    
    // QWidget window;
    // window.resize(650, 350);
    // window.setWindowTitle("简单的cmake构建的Qt窗口程序");
    // window.show();
  
    return app.exec();
}
